import { getShop, getApply, shopApply, shopName, shopTel, shopStatus,shopStop } from "../apis/shop";
export default {
    state: {
        shopList: [],
        applyList: [],
        applyResult: false,
        shopNameCode: '',
        shopTelCode: '', 
        shopStatusCode: '',
        shopStopCode: null,
    },
    effects: {
        *getShopBySaga({ payload }, { put, call }) {
            const res = yield call(getShop, payload)
            // console.log(res);
            yield put({ type: "initShop", payload: res.rows })
        },
        *getApplyBySaga({ payload }, { put, call }) {
            const res = yield call(getApply, payload)
            // console.log(res);
            yield put({ type: "initApplyShop", payload: res.rows })
        },
        *shopApplyBySaga({ payload }, { put, call }) {
            const res = yield call(shopApply, payload)
            // console.log(res);
            yield put({ type: "applyCode", payload: res.result })
        },
        *shopNameBySaga({ payload }, { put, call }) {
            const res = yield call(shopName, payload)
            // console.log(res);
            yield put({ type: "shopNameCode", payload: res.boo })
        },
        *shopTelBySaga({ payload }, { put, call }) {
            const res = yield call(shopTel, payload)
            // console.log(res);
            yield put({ type: "shopTelCode", payload: res.boo })
        },
        *shopStatusBySaga({ payload }, { put, call }) {
            const res = yield call(shopStatus, payload)
            // console.log(res);
            yield put({ type: "shopStatusCode", payload: res })
        },
        *shopStopBySaga({ payload }, { put, call }) {
            const res = yield call(shopStop, payload)
            // console.log(res);
            yield put({ type: "shopStopCode", payload: res })
        },
    },
    reducers: {
        initShop(state, action) {
            state.shopList = action.payload
            return state
        },
        initApplyShop(state, action) {
            state.applyList = action.payload
            return state
        },
        applyCode(state, action) {
            state.applyResult = action.payload
            return state
        },
        shopNameCode(state, action) {
            state.shopNameCode = action.payload
            return state
        },
        shopTelCode(state, action) {
            state.shopTelCode = action.payload
        },
        shopStatusCode(state, action) {
            state.shopStatusCode = action.payload
        },
        shopStopCode(state, action) {
            state.shopStopCode = action.payload
        },
    }
}